********//dofile for obtianing age-earnings profile from ACS********
use "$data/ACS/usa_00025", clear

//sample restrictions
drop if empstat == 0
keep if age>=19 & age<=65 //restricted age range
keep if bpl<60 //US natives

//create hours variable
gen hours = uhrswork
replace hours = hours * 20 if wkswork2 == 2
replace hours = hours * 33 if wkswork2 == 3
replace hours = hours * 43.5 if wkswork2 == 4
replace hours = hours * 48.5 if wkswork2 == 5
replace hours = hours * 51 if wkswork2 == 6
gen wage = incwage / hours //hourly wage

//hours restrictions
drop if educ<6 //at least HS

//college dummy
gen coll = (educ>=10)
gen coll2 = (educd>=71)
gen hs = (educ == 6) //high school dummy
drop if educd == 61 //no HS diploma
drop if educ == 11 //remove advanced degrees!

//educational attainment
gen educ_cat = 0
replace educ_cat = 1 if educd<80
replace educ_cat = 2 if educd == 81
replace educ_cat = 3 if educd>81

//variable restriction
keep incwage wage hours educ_cat age year perwt hs empstat school relate
compress

//deflate money stuff
merge m:1 year using "$data/GDP/gdp_pce_deflator", keep(match) nogen
replace deflator = deflator/100 //normalize
replace incwage = incwage/deflator //deflate labor income
replace wage = wage/deflator

//sample restrictions
gen deflator_2000 = 0.78235
gen incwage_2000 = incwage * deflator_2000
drop if age>30 & (hours<520 | incwage_2000<6000) & empstat == 1 //adequate work for older heads
drop if age<=30 & (hours<260 | incwage_2000<4000) & empstat == 1 //adequate work for older heads
drop if hours>5820 //too many hours

//normalizing wage
//su wage if hs & age == 19 & hours>1560 [fw=perwt] //average wage for 19-year old conditional on strong LF attachment
//keep if age>=23 //restricted age range

//convert stuff to logs
gen loginc = log(incwage)
replace school = school - 1
drop if school == 1 & age>23 //nix people who are in school after certain age. 

//save smaller version
keep if relate == 1 //limit to household heads
compress
save "$temp/ACS_profile_data", replace
